.host {
  border-radius: 50%;
}

.in {
  display: flex;
  flex-flow: column wrap;
  inline-size: 100%;
  block-size: 100%;
  overflow: hidden;
  border-radius: inherit;
}

.item {
  inline-size: calc(50% - var(--vkui_internal--grid_avatar_image_offset) / 2);
  block-size: calc(50% - var(--vkui_internal--grid_avatar_image_offset) / 2);
  margin-inline-end: var(--vkui_internal--grid_avatar_image_offset);
  background-position: center;
  background-size: cover;
}

.item:only-child {
  inline-size: 100%;
}

.item:first-child:not(:nth-last-child(4)),
.item:nth-child(2):last-child {
  block-size: 100%;
}

/* если есть минимум три элемента — выбираем второй с конца */
.item:nth-last-child(n + 3) ~ .item:nth-last-child(2),
/* четвертый с конца */
  .item:nth-last-child(4) {
  margin-block-end: var(--vkui_internal--grid_avatar_image_offset);
}
